package cn.net.shuxing.yifu.common.util;

import java.lang.reflect.Constructor;
import java.time.LocalTime;

public class LocalTimeUtil {

    public static LocalTime createLocalTime(int hour, int minuminute, int second, int nanoOfSecond) {
        Class<LocalTime> localTimeClass = LocalTime.class;
        try {
            Constructor<?> constructor = localTimeClass.getDeclaredConstructors()[0];
            constructor.setAccessible(true);
            LocalTime localTime = (LocalTime)constructor.newInstance(hour,minuminute,second,nanoOfSecond);
            return localTime;
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 创建一个0时0分0秒0纳秒的LocalTime对象
     * @return
     */
    public static LocalTime createLocalTimeInZero()
    {
        return createLocalTime(0,0,0,0);
    }
}
